<template>
    <div>
        <top-simple-search @searchFun="query" @addFun="handleAdd" @exportFun="toExport" :showExport="isAll">
            <el-form-item label="" prop="dept_id">
                <dept-select-tree v-model="formData.dept_id"  v-if="params.category=='all'" placeholder="请选择提交部门" style="width: 220px" :appendToBody="true" zIndex="2100" :disable-branch-nodes="true"></dept-select-tree>
            </el-form-item>
            <el-form-item label="">
                <el-date-picker
                        v-model="formData.starttime"
                        value-format="yyyy-MM-dd"
                        type="date"
                        placeholder="提交开始日期">
                </el-date-picker>
            </el-form-item>
            <el-form-item label="">
                <el-date-picker
                        v-model="formData.endtime"
                        value-format="yyyy-MM-dd"
                        type="date"
                        placeholder="提交结束日期">
                </el-date-picker>
            </el-form-item>
            <el-form-item label="">
                <el-select v-model="formData.is_draft" placeholder="请选择状态" clearable>
                    <el-option label="审批中" :value="0"></el-option>
                    <el-option label="未通过" :value="2"></el-option>
                    <el-option label="通过" :value="3"></el-option>
                    <el-option label="已上会" :value="4"></el-option>
                    <el-option label="已完结" :value="5"></el-option>
                </el-select>
            </el-form-item>
          <template  slot="other-button">
            <primary-button handle="dengji" @click="handleAdd({is_draft:3})">登记</primary-button>
          </template>
        </top-simple-search>
        <simple-table ref="myTable" :params="params" v-on="$listeners"  v-bind="$attrs">
            <el-table-column align="left" prop="title" label="标题" show-tooltip-when-overflow min-width="200">
                <template slot-scope="{row}">
                    <my-link @to="toView(row)">{{row.title}}</my-link>
                </template>
            </el-table-column>
            <my-dict-column dist-key="huiyi_yiti_type" prop="type_id" label="议题类型" width="150"></my-dict-column>
            <el-table-column align="left" prop="dept_name" label="部门" width="150">
            </el-table-column>
            <el-table-column align="left" prop="participant" label="当前办理人"  min-width="200" v-if="isFaqi||isYiban||isAll">
                <template slot-scope="{row}">
                    <span  v-if="row.participant">{{row.participant}}</span>
                    <span v-else-if="row.act_state_id==4">
                        已办结
                    </span>
                </template>
            </el-table-column>
            <el-table-column align="left" prop="alias" label="申请人" width="150" v-if="isTodo||isYiban"/>
            <el-table-column align="left" prop="is_draft" label="申请状态"  width="120">
                <template slot-scope="{ row }">
                    <span v-if="row.is_draft == 0" class="yellowSpan">审批中</span>
                    <span v-if="row.is_draft == 1">草稿</span>
                    <span v-if="row.is_draft == 2" class="redSpan">未通过</span>
                    <span v-if="row.is_draft == 3" class="greenSpan">通过</span>
                    <span v-if="row.is_draft == 4" class="greenSpan">已上会</span>
                    <span v-if="row.is_draft == 5">已完结</span>
                </template>
            </el-table-column>
            <el-table-column align="left" prop="gmt_created" label="提交时间" width="170">
            </el-table-column>
            <el-table-column align="left" fixed="right" label="操作" width="150">
                <template slot-scope="{row}">
                    <edit-button v-if="(isDraft||row.is_edit&&isTodo)"  @click="toEdit(row)"></edit-button>
                    <my-button handle="chuli" v-else-if="isTodo" @click="toHandle(row)">处理</my-button>
                    <detail-button v-else @click="toView(row)"></detail-button>
                    <delete-button v-if="isDelete"  @click="toDelete(row.id)"></delete-button>
                    <my-button handle="print" @click="toPrint(row.id)" v-if="row.is_draft == 3||row.is_draft == 4||row.is_draft==5">打印</my-button>
                    <my-button handle="cancel"  @click="toCancel(row)" v-if="isFaqi">取消</my-button>
                    <my-button handle="retreat"  @click="setTicketsRetreat(row)" v-if="isFaqi">撤回</my-button>
                    <my-button handle="banjie" @click="toBanjie(row.id)" v-if="row.is_draft==4&&(isAll||isFaqi)">已完结</my-button>
                </template>
            </el-table-column>
        </simple-table>
    </div>
</template>
<script>
    import MyLink from "../../../components/MyLink/index";
    import ExtendTable from "@/mixins/ExtendTable";
    import DeptSelectTree from "@/components/Common/DeptSelectTree";
    import MyDictColumn from "../../../components/TableColumn/MyDictColumn";
    import PrimaryButton from "../../../components/Buttons/PrimaryButton";
    import simpleMeetTopics from "@/api/huiyi/simpleMeetTopics/index"
    export default {
        name: "ListTable",
        components: {PrimaryButton, MyDictColumn, MyLink, DeptSelectTree},
        mixins: [ExtendTable],
        props: ["params"],
        data() {
            return {
                formData:{
                    dept_id:undefined,
                    starttime:undefined,
                    endtime:undefined,
                    search_value:undefined,
                    is_draft:undefined
                },
            }
        },
        created() {
        },
        computed: {
        },
        methods: {
            query(queryData) {
                this.formData.search_value = queryData
                this.$refs["myTable"].searchList(this.formData);
            },
            toBanjie(id){
              this.$confirm("议题办结, 是否继续?", "提示", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning"
              }).then(() => {
                simpleMeetTopics.yitiEnd(id).then(res=>{
                  this.msgSuccess(res.msg)
                  this.getList()
                })
              });
            }
        }
    }
</script>
